package de.karlNet.sambamanager.view.beans.forms;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Controller;

import de.karlNet.sambamanager.ldapController.commands.RenameLdapObject;
import de.karlNet.sambamanager.ldapModel.LdapContainer;

@Controller
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class EditOUBean extends CreateOUBean {
	@Autowired
	private RenameLdapObject renameLdapObject;

	@Override
	public void setShow(boolean show) {
		this.container = (LdapContainer) this.nodeContainer.selectedNode
				.getLdapObject();
		super.setShow(show);
	}

	@Override
	public String getPageName() {
		return "editOUVIew";
	}

	@Override
	public String create() {
		try {
			this.renameLdapObject.renameLdapObject(container);
			this.setShow(false);
			return "index.xhtml";
		} catch (Exception e) {
			this.showErrorMessage(e);
			return "";
		}
	}
}
